﻿using System;
using System.Windows.Forms;
using System.Text;

namespace DesignerHelper.Help
{
    public static class MesBox
    {
        private static string FormatMes(Exception ex)
        {
            return $"{ex.TargetSite}{'\n'}{ex.Source}{'\n'}{ex.Message}{'\n'}{ex.GetType()}{'\n'}{ex.StackTrace}";
        }
        public static DialogResult ErrorMessage(Exception ex)
        {
            return MessageBox.Show(FormatMes(ex), About.MyName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
        }
        public static DialogResult ErrorMessage(string ex)
        {
            return MessageBox.Show(ex, About.MyName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
        }

        public static DialogResult InfoMessage(Exception ex)
        {
            return MessageBox.Show(FormatMes(ex), About.MyName, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        public static DialogResult InfoMessage(string ex)
        {
            return MessageBox.Show(ex, About.MyName, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        public static DialogResult WarningMessage(Exception ex)
        {
            return MessageBox.Show(FormatMes(ex), About.MyName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }

        public static DialogResult QuestionMessage(string str)
        {
            return MessageBox.Show(str, About.MyName, MessageBoxButtons.YesNo, MessageBoxIcon.Information);
        }
    }
}
